package com.matriq.cloudmanager;

import com.matriq.cloudmanager.R;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
import net.lgpage.activity.BaseActivity;
import net.lgpage.http.ExceptionAsyncTask;
import net.lgpage.util.Checker.StringChecker;

public class AddCourseEvalActivity extends BaseActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_add_course_eval);
		setViews();
		setEvents();
		loadData();
	}

	TextView tv[] = new TextView[4];
	TextView tv_title;
	EditText et;
	ImageButton ll_back;
	Button bt_commit;
	Button bt_save;

	private void setViews() {
		tv[0] = (TextView) this.findViewById(R.id.tv0);
		tv[1] = (TextView) this.findViewById(R.id.tv1);
		tv[2] = (TextView) this.findViewById(R.id.tv2);
		tv[3] = (TextView) this.findViewById(R.id.tv3);
		tv_title = (TextView) this.findViewById(R.id.tv_title);
		et = (EditText) this.findViewById(R.id.et);
		ll_back = (ImageButton) this.findViewById(R.id.ll_back);
		bt_commit = (Button) this.findViewById(R.id.bt_commit);
		bt_save = (Button) this.findViewById(R.id.bt_save);
	}

	private void setEvents() {
		bt_commit.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {

			}
		});
		bt_save.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {

			}
		});
	}

	Object copyObj;

	public boolean checkEts() {
		if (copyObj == null) {
			copyObj = new Object();
		}

		String str_et = et.getEditableText().toString();

		if (StringChecker.isNull(str_et)) {
			setError("不能为空", et);
			return false;
		}

		return true;
	}

	ObjTask objTask;

	public void putObj() {
		if (objTask != null) {
			objTask.cancel(true);
		}
		objTask = new ObjTask(this);
		objTask.execute();
	}

	private class ObjTask extends ExceptionAsyncTask<Object> {

		public ObjTask(Context context) {
			super(context);
		}

		@Override
		public Object doInBackgroundX(String... params) throws Exception {
			return null;
		}

		@Override
		public void onPostExecuteX(Object result) {
			if (result == null) {
				return;
			} else {
				obj = result;
				// Snackbar.make(this, "成功", 1).show();
			}
		}
	}

	Object obj;

	public void setData(Object obj) {
		this.obj = obj;
		tv[0].setText(null);
		tv[1].setText(null);
		tv[2].setText(null);
		tv[3].setText(null);
		tv_title.setText(null);
		et.setText(null);
		et.setSelection(et.length());
	}

	private void loadData() {

	}

	@Override
	public void onDestroy() {

		super.onDestroy();
	}

}